/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package clienteservidor.servidor;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import clienteservidor.cliente.gui.HiloCliente;


/**
 *
 * @author Andrés Gaitán
 */
public class MainServidor
{
    public static void main(String [] args)
    {
        ServerSocket socket = null;
        try
        {
           socket = new ServerSocket(4090);
           while (true)
           {
               Socket sk = socket.accept();

               /*
               BufferedReader entrada = new BufferedReader(new InputStreamReader(sk.getInputStream()));
               PrintWriter salida = new PrintWriter(sk.getOutputStream(), true);
               System.out.println("Se conecto el cliente: " + sk.getInetAddress());
               String resp = entrada.readLine();
               System.out.println("Mensaje Recibido: " + resp);
               salida.println("Mensaje recibido\n");
                */
               
               HiloCliente hilo = new HiloCliente(sk);
               Thread th = new Thread(hilo);
               th.start();
           }
        }catch(IOException e)
        {
            System.err.println("Error de tipo IOException: " + e.getMessage());
            e.printStackTrace();
        }finally
        {
            try
            {
                socket.close();
            }catch (IOException e)
            {
                System.err.println("Error de tipo IOException: " + e.getMessage());
                e.printStackTrace();
            }
        }
    }
}
